﻿namespace KinonekoSoftware.JuXiaoYouDB.SubSystem
{
    partial class GlossaryDB
    {
        
        //-------------------------------------------------------------
        //
        //          Public Methods
        //
        //-------------------------------------------------------------
        public IEnumerable<Glossary> GetGlossaries()            => _GlossaryCollection.Find(x => !x.IsDeleted);
        public IEnumerable<Glossary> GetGlossaries(string type) => _GlossaryCollection.Find(x => !x.IsDeleted && x.TypeName == type);


        public void Add(Glossary glossary)
        {
            if (glossary is null)
            {
                return;
            }

            _GlossaryCollection.Insert(glossary);
            _VersionGlossary++;
        }

        public void Update(Glossary glossary)
        {
            if (glossary is null)
            {
                return;
            }

            _GlossaryCollection.Update(glossary);
            _VersionGlossary++;
        }
        
        public void Remove(Glossary glossary)
        {
            if (glossary is null)
            {
                return;
            }

            _GlossaryCollection.Delete(glossary.Id);
            _VersionGlossary++;
        }
        
        
        //-------------------------------------------------------------
        //
        //          Properties
        //
        //-------------------------------------------------------------
        public int CountOfGlossary   => _GlossaryCollection.Count();
        public int VersionOfGlossary => _VersionGlossary;
    }
}